<template>
 <div>
   <div v-for="item in fUser" class="mes">
      <el-tag type="success" style="font-size: 16px">{{item.username}}给您发来了{{item.num}}条消息,点击
        <a href="javascript:void(0)" style="color: red" @click="openDialog(item.username)">查看</a>
      </el-tag>

   </div>
 </div>
</template>

<script>
export default {
  data(){
    return{
       userNum:0,
       Mes:[],
       user: [],
       fUser:[],
    }
  },
  methods:{
      openDialog(username){
        let _this = this
        this.$axios({
          method:"GET",
          url:"http://localhost/user_admin/read/admin"+username
        }).then(result => {

        })



        this.$axios({
           method:"GET",
           url:"http://localhost/user_admin/read/admin/"+username
        }).then(response=>{

        })

        this.$router.push({
          path: "/chatAdmin",
          query: {
            username: username,
          }

        });
      },

     mesCenter() {
       let _this = this
       this.$axios({
          method:"GET",
          url : "http://localhost/user/findUserMes"
       }).then(result => {
          _this.user=result.data

         _this.$axios({
           method:"GET",
           url:"http://localhost/user_admin/mesCenter",
         }).then(result => {
           _this.Mes=result.data
           for(let i of _this.Mes){
             for(let j of _this.user){
               if(i.sender==j.username)
               {
                 j.num++
               }
             }

           }
           for(let i of _this.user)
           {
              if(i.num!=0)
              {

                _this.fUser.push(i)
              }

           }

         })

       })





     },
  },
  mounted() {
      this.mesCenter()
  }
}
</script>

<style scoped>
.mes{
  position: relative;
   height: 40px;
   width: 60px;
  left: 500px;

}
</style>




